package com.eims.sls_app.ui.adapter;

import bls.juejin.cn.R;

import com.eims.sls_app.ui.adapter.CenterLotteryAdapter.ViewHolder;
import com.eims.sls_app.view.MyListView2;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CaceGvAdapter extends BaseAdapter {
	private Context context;
	private int[] pic;
	private String[] title;
	private String[] subtitle;
	
	

	public CaceGvAdapter(Context context, int[] pic, String[] title,
			String[] subtitle) {
		super();
		this.context = context;
		this.pic = pic;
		this.title = title;
		this.subtitle = subtitle;
	}

	@Override
	public int getCount() {

		return pic.length;
	}

	@Override
	public Object getItem(int position) {

		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder;
		if (view==null) {
			holder = new ViewHolder();
			LayoutInflater inflact = LayoutInflater.from(context);
			view = inflact.inflate(R.layout.gridview_items_cace, null);
			holder.tv_title = (TextView) view.findViewById(R.id.tv_title_gv);
			holder.tv_subtitle = (TextView) view.findViewById(R.id.tv_subtitle_gv);
			holder.iv_pic = (ImageView) view.findViewById(R.id.iv_pic_gv);
			view.setTag(holder);
		}else {
			holder = (ViewHolder) view.getTag();
		}
		holder.iv_pic.setImageResource(pic[position]);
		holder.tv_title.setText(title[position]);
		holder.tv_subtitle.setText(subtitle[position]);
		return view;
	}
	
	static class ViewHolder {
		TextView tv_title, tv_subtitle;
		ImageView iv_pic;
	}

}
